1583A - Windblume Ode - CodeForces Solution


math number theory *800

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long int
#define pb push_back
#define pf push_front
#define en cout<<endl;
#define yes cout<<"YES"<<endl;
#define no  cout<<"NO"<<endl;
#define no1 {cout<<-1<<endl; r0}
#define no0 {cout<<0<<endl; r0}
#define yes_r { cout<<"YES"<<endl; return ; }
#define no_r { cout<<"NO"<<endl; return ; }
#define r0 return ;
#define fr first
#define sc second
#define srt(name) sort(name.begin(), name.end());
#define rev(name) reverse(name.begin(), name.end());
#define TT { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; int tt; cin>>tt; while (tt--) not_main(); }
#define TT1 { not_main(); }
#define TTi { while(1) no
#define IMP { cout<<"IMPOSSIBLE"<<endl; r0 }

const int INF=1e9+1;
const int mod=998244353;
const int N=1e5+1;

void not_main()
{
    ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    ll n; cin>>n;
    ll v[n];
    for (ll i=0; i<n; i++) cin>>v[i];
    ll sum=0;
    ll pos=-1;

    for (ll i=0; i<n; i++){
        sum+=v[i];
        if (v[i]%2==1) pos=i+1;
    }
    //cout<<sum<<endl;

    bool sostav=false;
    ll cr=0;
    for (ll i=1; i<=sum; i++){
        if (sum%i==0) cr++;
        if (cr==3){
            sostav=true;
            break;
        }
    }
    //cout<<cr<<endl;

    if (sostav==true){
        cout<<n<<endl;
        for (ll i=1; i<=n; i++) cout<<i<<' ';
        en
    }
    else
    {
        cout<<n-1<<endl;
        for (ll i=1; i<=n; i++){
            if (i!=pos) cout<<i<<' ';
        }
        en
    }
}

int main(){
    TT
}
///CHECK TT CLASS
/* comment box */
/**

**/

/** MAY BE USEFUL: **/
/*
#include<windows.h>
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    string all = "abcdefghijklmnopqrstuvwxyz";
    string Call= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string Vow = "aeiou"
*/


Comments

Submit
0 Comments
More Questions

Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!